package org.vincen.helloworld.mybatis;

import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

public class UserDaoTest {
	
	@Test
	public void userDaoTest () throws IOException {
		Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");
		SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(reader);
		SqlSession session = factory.openSession();
		UserDao userDao = session.getMapper(UserDao.class);
		User user = new User();
		user.setName("vincen");
		user.setPassword("vincen");
		userDao.insert(user);
		session.commit();
		session.close();
	}

}
